//
// Created by 21577 on 2025/3/7.
//
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

// 比较函数，用于qsort排序
int cmp(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

// 二分查找最接近值的差值
int binary_search(int *arr, int len, int target) {
    int left = 0, right = len - 1;
    int min_diff = 1000000; // 初始化为较大值
    while (left <= right) {
        int mid = left + (right - left) / 2;
        min_diff = fmin(min_diff, abs(arr[mid] - target)); // 更新最小差值
        if (arr[mid] < target) {
            left = mid + 1;
        } else {
            right = mid - 1;
        }
    }
    return min_diff;
}

int main() {
    int n;
    scanf("%d", &n);
    int a[n], b[n];
    // 读取数组a
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    // 读取数组b
    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }
    // 对数组b排序
    qsort(b, n, sizeof(int), cmp);

    int min_val = 1000000; // 初始化最小差值
    // 遍历数组a，对每个元素在b中查找最接近值
    for (int i = 0; i < n; i++) {
        int current_diff = binary_search(b, n, a[i]);
        if (current_diff < min_val) {
            min_val = current_diff;
        }
    }
    printf("%d\n", min_val);
    return 0;
}